package org.duiduo.feign;

import org.duiduo.api.bean.UserAddressVO;
import org.duiduo.api.bean.UserVO;
import org.duiduo.api.request.UserFindPageRequest;
import org.duiduo.api.response.Page;
import org.duiduo.api.response.Result;
import org.duiduo.api.valid.ValidationGroups;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 用户管理
 *
 * @author liangze
 * @date 2021/9/22 19:01
 */
@FeignClient(value = "duiduo-service", path = "user", contextId = "duiduoUserService")
interface DuiduoUserService {

    /**
     * 统计数据
     *
     * @return
     */
    @GetMapping("/count")
    Result<List<UserAddressVO>> count();

    /**
     * 新增保存
     *
     * @param userVO
     */
    @PostMapping
    void save(@RequestBody @Validated(ValidationGroups.Insert.class) UserVO userVO);

    /**
     * 编辑修改
     *
     * @param userVO
     */
    @PutMapping
    void update(@RequestBody @Valid @Validated(ValidationGroups.Update.class) UserVO userVO);

    /**
     * 删除
     *
     * @param id
     */
    @DeleteMapping("/{id}")
    void delete(@PathVariable Long id);

    /**
     * 分页查询
     *
     * @param request
     * @return
     */
    @PostMapping("/query")
    Result<Page<UserVO>> findPage(@RequestBody UserFindPageRequest request);
}
